package com.yxinmiracle.goods.service.impl;

import com.yxinmiracle.core.service.impl.CoreServiceImpl;
import com.yxinmiracle.goods.dao.CategoryMapper;
import com.yxinmiracle.goods.pojo.Category;
import com.yxinmiracle.goods.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/****
 * @Author:admin
 * @Description:Category业务层接口实现类
 * @Date 2019/6/14 0:16
 *****/
@Service
public class CategoryServiceImpl extends CoreServiceImpl<Category> implements CategoryService {

    private CategoryMapper categoryMapper;

    @Autowired
    public CategoryServiceImpl(CategoryMapper categoryMapper) {
        super(categoryMapper, Category.class);
        this.categoryMapper = categoryMapper;
    }

    /**
     * 根据条件来查询
     * select * from tb_category where parent_id=?
     * @param pid
     * @return
     */
    @Override
    public List<Category> findByParentId(Integer pid) {
        /*
        出于练习情况 自己练习写一个
        Category category = new Category();
        category.setParentId(pid); // where parent_id=pid
        List<Category> categoryList = categoryMapper.select(category);
        */
        return categoryMapper.findByParentId(pid);
    }
}
